package com.jida.hadoop.mr.wz.countpv;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Reducer.Context;

import com.jida.hadoop.mr.wz.dataclean.TProperties;

public class CountPvReducer extends Reducer<Text, IntWritable, NullWritable, Text> {
	private IntWritable cnt = new IntWritable();
	private Text result = new Text();
	public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
		int sum = 0;
		for (IntWritable val : values) {
			sum += val.get();
		}
		cnt.set(sum);
		String tmp = key + TProperties.getValue("outfilesplit")+ cnt.toString();
		result.set(tmp);
		context.write(NullWritable.get(), result);
	}
}
